﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;

namespace PHMEE
{
    public class TdDataSeedManagerFactory
    {
        private readonly Dictionary<DbPrefixEnum, ITdDataSeedManager> _managerMap;

        public TdDataSeedManagerFactory(IEnumerable<ITdDataSeedManager> managers)
        {
            _managerMap = managers.ToDictionary(m => m.DatabaseType, m => m);
        }

        public ITdDataSeedManager GetManager(DbPrefixEnum dbPrefix)
        {
            if (!_managerMap.TryGetValue(dbPrefix, out var manager))
            {
                throw new UserFriendlyException($"找不到对应数据库前缀的Manager {dbPrefix}");
            }
            return manager;
        }
    }

}
